package com.example.lanqiaodemo1.JavaTest7;

import java.io.*;

public class OutIn2 {

    public static void out2() throws Exception {
        File f = new File("d:\\out2.txt");
        FileWriter fw = new FileWriter(f);
        for (int i = 1; i <= 100; i++) {
            String s = String.valueOf(i);
            fw.write(s);
        }
        fw.close();
    }

    public static void in2() throws Exception {
        File f = new File("d:\\out2.txt");
        FileReader fr = new FileReader(f);
        int n = 0;
        while ((n = fr.read())!= -1) {
            System.out.print((char) n);
        }
        fr.close();
    }

    public static void main(String[] args) {
        try {
            OutIn2.out2();
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            OutIn2.in2();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}

